﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008">
	<!-- NormalBrush is used as the Background for SimpleButton -->
	<LinearGradientBrush x:Key="NormalBrush" EndPoint="0,1" StartPoint="0,0">
		<GradientStop Color="#EEE" Offset="0.0"/>
		<GradientStop Color="#CCC" Offset="1.0"/>
	</LinearGradientBrush>
	<LinearGradientBrush x:Key="NormalBorderBrush" EndPoint="0,1" StartPoint="0,0">
		<GradientStop Color="#CCC" Offset="0.0"/>
		<GradientStop Color="#444" Offset="1.0"/>
	</LinearGradientBrush>
	
	<!-- LightBrush is used for content areas such as Menu, Tab Control background -->
	<LinearGradientBrush x:Key="LightBrush" EndPoint="0,1" StartPoint="0,0">
		<GradientStop Color="#FFF" Offset="0.0"/>
		<GradientStop Color="#EEE" Offset="1.0"/>
	</LinearGradientBrush>
	
	<!-- MouseOverBrush is used for MouseOver in Button, Radio Button, CheckBox -->
	<LinearGradientBrush x:Key="MouseOverBrush" EndPoint="0,1" StartPoint="0,0">
		<GradientStop Color="#FFF" Offset="0.0"/>
		<GradientStop Color="#AAA" Offset="1.0"/>
	</LinearGradientBrush>
	
	<!-- PressedBrush is used for Pressed in Button, Radio Button, CheckBox -->
	<LinearGradientBrush x:Key="PressedBrush" EndPoint="0,1" StartPoint="0,0">
		<GradientStop Color="#BBB" Offset="0.0"/>
		<GradientStop Color="#EEE" Offset="0.1"/>
		<GradientStop Color="#EEE" Offset="0.9"/>
		<GradientStop Color="#FFF" Offset="1.0"/>
	</LinearGradientBrush>
	<LinearGradientBrush x:Key="PressedBorderBrush" EndPoint="0,1" StartPoint="0,0">
		<GradientStop Color="#444" Offset="0.0"/>
		<GradientStop Color="#888" Offset="1.0"/>
	</LinearGradientBrush>

	<!-- SelectedBackgroundBrush is used for the Selected item in ListBoxItem, ComboBoxItem-->
	<SolidColorBrush x:Key="SelectedBackgroundBrush" Color="#DDD"/>	

	<!-- Disabled Brushes are used for the Disabled look of each control -->
	<SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888"/>
	<SolidColorBrush x:Key="DisabledBackgroundBrush" Color="#EEE"/>
	<SolidColorBrush x:Key="DisabledBorderBrush" Color="#AAA"/>

	<!-- Used for background of ScrollViewer, TreeView, ListBox, Expander, TextBox, Tab Control -->
	<SolidColorBrush x:Key="WindowBackgroundBrush" Color="#FFF"/>
	
	<!-- DefaultedBorderBrush is used to show KeyBoardFocus -->
	<LinearGradientBrush x:Key="DefaultedBorderBrush" EndPoint="0,1" StartPoint="0,0">
		<GradientStop Color="#777" Offset="0.0"/>
		<GradientStop Color="#000" Offset="1.0"/>
	</LinearGradientBrush>

	<SolidColorBrush x:Key="SolidBorderBrush" Color="#888"/>
	<SolidColorBrush x:Key="LightBorderBrush" Color="#AAA"/>
	<SolidColorBrush x:Key="LightColorBrush" Color="#DDD"/>

    <SolidColorBrush x:Key="ButtonBackgroundBorder" Color="#FF4C4C4C"/>
    
    <!-- Used for Checkmark, Radio button, TreeViewItem, Expander ToggleButton glyphs -->
	<SolidColorBrush x:Key="GlyphBrush" Color="#444"/>
	
	<!-- SimpleButtonFocusVisual is used to show keyboard focus around a SimpleButton control -->
	<Style x:Key="SimpleButtonFocusVisual">
		<Setter Property="Control.Template">
			<Setter.Value>
				<ControlTemplate>
					<Border>
						<Rectangle Margin="2" Stroke="#60000000" StrokeThickness="1" StrokeDashArray="1 2"/>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	
	<!-- Simple Button - This control sets brushes on each state. -->
	<Style x:Key="SimpleButton" TargetType="{x:Type Button}">
		<Setter Property="FocusVisualStyle" Value="{DynamicResource SimpleButtonFocusVisual}"/>
		<Setter Property="Background" Value="{DynamicResource NormalBrush}"/>
		<Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Button}">
					
					<!-- We use Grid as a root because it is easy to add more elements to customize the button -->
					<Grid x:Name="Grid">
						<Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"/>
						
						<!-- Content Presenter is where the text content etc is placed by the control -->
						<!-- The bindings are useful so that the control can be parameterized without editing the template -->
						<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
					</Grid>
					
					<!--Each state sets a brush on the Border in the template -->
					<ControlTemplate.Triggers>
						<Trigger Property="IsKeyboardFocused" Value="true">
							<Setter Property="BorderBrush" Value="{DynamicResource DefaultedBorderBrush}" TargetName="Border"/>
						</Trigger>
						<Trigger Property="IsMouseOver" Value="true">
							<Setter Property="Background" Value="{DynamicResource MouseOverBrush}" TargetName="Border"/>
						</Trigger>
						<Trigger Property="IsPressed" Value="true">
							<Setter Property="Background" Value="{DynamicResource PressedBrush}" TargetName="Border"/>
							<Setter Property="BorderBrush" Value="{DynamicResource PressedBorderBrush}" TargetName="Border"/>
						</Trigger>
						<Trigger Property="IsEnabled" Value="false">
							<Setter Property="Background" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border"/>
							<Setter Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" TargetName="Border"/>
							<Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	
	<!-- Simple ScrollRepeatButton Style - This RepeatButton is used above and below the Thumb in the Scrollbar. They are set to transparent si that they do not show over the scrollbar -->
	<Style x:Key="SimpleScrollRepeatButtonStyle" d:IsControlPart="True" TargetType="{x:Type RepeatButton}">
		<Setter Property="Background" Value="Transparent"/>
		<Setter Property="BorderBrush" Value="Transparent"/>
		<Setter Property="IsTabStop" Value="false"/>
		<Setter Property="Focusable" Value="false"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type RepeatButton}">
					<Grid>
						<Rectangle Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}"/>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	
	<!-- Simple ScrollBar  This makes use of SimpleThumb, and SimpleScrollRepeatButton -->	
	<Style x:Key="SimpleScrollBar" TargetType="{x:Type ScrollBar}">
		<Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
		<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
		<Setter Property="Template" Value="{DynamicResource ScrollBarControlTemplate}"/>
	</Style>
	
	<!-- Simple ScrollViewer 
	ScrollViewer is a Grid control which has a ContentPresenter and a Horizontal and Vertical ScrollBar 
	It is used by ListBox -->
	<Style x:Key="SimpleScrollViewer" TargetType="{x:Type ScrollViewer}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type ScrollViewer}">
					<Grid Background="{TemplateBinding Background}">
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="*"/>
							<ColumnDefinition Width="Auto"/>
						</Grid.ColumnDefinitions>
						<Grid.RowDefinitions>
							<RowDefinition Height="*"/>
							<RowDefinition Height="Auto"/>
						</Grid.RowDefinitions>
						<ScrollContentPresenter Grid.Column="0" Grid.Row="0" Margin="{TemplateBinding Padding}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" CanContentScroll="{TemplateBinding CanContentScroll}"/>
						
						<!-- The visibility of the ScrollBars is controlled by the implementation fo the control -->
						<ScrollBar Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Grid.Column="0" Grid.Row="1" x:Name="PART_HorizontalScrollBar" Style="{DynamicResource SimpleScrollBar}" Orientation="Horizontal" Value="{Binding Path=HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}" Minimum="0" Maximum="{TemplateBinding ScrollableWidth}" AutomationProperties.AutomationId="HorizontalScrollBar" d:IsHidden="True"/>
						<ScrollBar Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Grid.Column="1" Grid.Row="0" x:Name="PART_VerticalScrollBar" Style="{DynamicResource SimpleScrollBar}" Orientation="Vertical" Value="{Binding Path=VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}" Minimum="0" Maximum="{TemplateBinding ScrollableHeight}" AutomationProperties.AutomationId="VerticalScrollBar"/>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	
	<!-- Simple ListBox - This uses SimpleScrollViewer to allow items to be scrolled and SimpleListBoxItem to define the look of each item -->
	<Style x:Key="SimpleListBox" TargetType="{x:Type ListBox}">
		<Setter Property="SnapsToDevicePixels" Value="true"/>
		<Setter Property="Background" Value="{DynamicResource WindowBackgroundBrush}"/>
		<Setter Property="BorderBrush" Value="{DynamicResource SolidBorderBrush}"/>
		<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
		<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
		<Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type ListBox}">
					<Grid>
						<ScrollViewer Margin="1" Style="{DynamicResource SimpleScrollViewer}" Focusable="false" Background="{TemplateBinding Background}">
							<!-- The StackPanel is used to display the children by setting IsItemsHost to be Trus -->
							<StackPanel Margin="2" IsItemsHost="true"/>
						</ScrollViewer>
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsGrouping" Value="true">
							<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	
	<!-- Simple ListBoxItem - This is used for each Item in a ListBox. The item's content is placed in the ContentPresenter -->	
	<Style x:Key="SimpleListBoxItem" d:IsControlPart="True" TargetType="{x:Type ListBoxItem}">
		<Setter Property="SnapsToDevicePixels" Value="true"/>
		<Setter Property="OverridesDefaultStyle" Value="true"/>        
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type ListBoxItem}">
					<Grid SnapsToDevicePixels="true">
						<Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"/>
						<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
					</Grid>
					<ControlTemplate.Triggers>						
						<Trigger Property="IsSelected" Value="true">
							<Setter Property="Background" Value="{DynamicResource SelectedBackgroundBrush}" TargetName="Border"/>
						</Trigger>						
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	
	<ControlTemplate x:Key="ScrollBarControlTemplate" TargetType="{x:Type ScrollBar}">
		<Grid x:Name="GridRoot" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
			<Grid.RowDefinitions>
				<RowDefinition MaxHeight="18" Height="0.061*"/>
				<RowDefinition Height="0.898*"/>
				<RowDefinition MaxHeight="18" Height="0.041*"/>
			</Grid.RowDefinitions>
						
			<Rectangle Margin="0,0.002,0,-0.002" Fill="#7FFFFFFF" Stroke="{DynamicResource ButtonBackgroundBorder}" RadiusX="5" RadiusY="5" Grid.RowSpan="3" StrokeThickness="0.5"/>
						
			<RepeatButton x:Name="DecreaseRepeat" Style="{DynamicResource RepeatButtonStyle}" Command="ScrollBar.LineUpCommand" Background="{x:Null}" BorderBrush="{x:Null}" Margin="0,0,0,-10.77" Cursor="Hand">
				<Grid>
					<Path x:Name="DecreaseArrow1" Stroke="#FFFFFFFF" StrokeThickness="1" Data="M0.50000001,0.49999999 L4.3732483,12.8917 8.5,0.49999999 z" Margin="6,2.596,6,0" VerticalAlignment="Top" Fill="#FFFFFFFF" Stretch="Fill" RenderTransformOrigin="0.5,0.5" Height="4.918">
						<Path.RenderTransform>
							<TransformGroup>
								<ScaleTransform ScaleX="1" ScaleY="1"/>
								<SkewTransform AngleX="0" AngleY="0"/>
								<RotateTransform Angle="-180"/>
								<TranslateTransform X="0" Y="0"/>
							</TransformGroup>
						</Path.RenderTransform>
					</Path>
				</Grid>
			</RepeatButton>
						
            <!-- Track is a special layout container which sizes the thumb and the repeat button which do jump scrolling either side of it -->
			<Track Grid.Row="1" x:Name="PART_Track" Orientation="Vertical" IsDirectionReversed="true" Margin="0,13.627,0,10.51" Cursor="Arrow">
				<Track.Thumb>
					<Thumb Style="{DynamicResource ThumbStyle}" Cursor="Hand">
						<Thumb.Background>
							<LinearGradientBrush EndPoint="8.801,64.856" StartPoint="28.801,64.856" MappingMode="Absolute">
								<LinearGradientBrush.Transform>
									<MatrixTransform Matrix="1,0,0,-1,-10.333,70.167"/>
								</LinearGradientBrush.Transform>
								<GradientStop Color="#FF323232" Offset="0"/>
								<GradientStop Color="#FFFFFFFF" Offset="1"/>
							</LinearGradientBrush>
						</Thumb.Background>
					</Thumb>
				</Track.Thumb>
				<Track.IncreaseRepeatButton>
					<RepeatButton x:Name="PageUp" Style="{DynamicResource SimpleScrollRepeatButtonStyle}" Command="ScrollBar.PageDownCommand"/>
				</Track.IncreaseRepeatButton>
				<Track.DecreaseRepeatButton>
					<RepeatButton x:Name="PageDown" Style="{DynamicResource SimpleScrollRepeatButtonStyle}" Command="ScrollBar.PageUpCommand" d:IsHidden="True" Background="#00770606"/>
				</Track.DecreaseRepeatButton>
			</Track>
						
			<RepeatButton Grid.Row="2" x:Name="IncreaseRepeat" Style="{DynamicResource RepeatButtonStyle}" Command="ScrollBar.LineDownCommand" Margin="0,-8.181,0,0.006" Cursor="Hand">
				<Grid>
					<Path x:Name="IncreaseArrow" Stroke="#FFFFFFFF" StrokeThickness="1" Data="M0.50000001,0.49999999 L4.3732483,12.8917 8.5,0.49999999 z" Margin="6,1.135,6,0" VerticalAlignment="Top" Height="5.61" Fill="#FFFFFFFF" Stretch="Fill" d:LayoutOverrides="VerticalAlignment"/>
				</Grid>
			</RepeatButton>
		</Grid>
					
		<!-- This uses a single template for ScrollBar and rotate it to be Horizontal
		It also changes the commands so that the it does Left and Right instead of Up and Down Commands -->
		<ControlTemplate.Triggers>
			<Trigger Property="Orientation" Value="Horizontal">

				<!-- Rotate the ScrollBar from Vertical to Horizontal -->
				<Setter Property="LayoutTransform" TargetName="GridRoot">
					<Setter.Value>
						<RotateTransform Angle="-90"/>
					</Setter.Value>
				</Setter>
							
				<!-- Track is bound to Orientation internally, so we need to rotate it back to Vertical -->
				<Setter TargetName="PART_Track" Property="Orientation" Value="Vertical"/>
					
				<!-- Change the commands to do Horizontal commands -->
				<Setter Property="Command" Value="ScrollBar.LineLeftCommand" TargetName="DecreaseRepeat"/>
				<Setter Property="Command" Value="ScrollBar.LineRightCommand" TargetName="IncreaseRepeat"/>
				<Setter Property="Command" Value="ScrollBar.PageLeftCommand" TargetName="PageDown"/>
				<Setter Property="Command" Value="ScrollBar.PageRightCommand" TargetName="PageUp"/>
			</Trigger>
		</ControlTemplate.Triggers>
	</ControlTemplate>
    
	<Style x:Key="RepeatButtonStyle" d:IsControlPart="True" TargetType="{x:Type RepeatButton}">
		<Setter Property="Background" Value="{DynamicResource NormalBrush}"/>
		<Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type RepeatButton}">
					<Grid>
						<Rectangle Margin="0,0,0,0" Stroke="{x:Null}" RadiusX="3" RadiusY="3">
							<Rectangle.Fill>
								<LinearGradientBrush EndPoint="32.161,59.666" StartPoint="12.161,59.666" MappingMode="Absolute">
									<LinearGradientBrush.Transform>
										<MatrixTransform Matrix="1,0,0,-1,-10.333,70.167"/>
									</LinearGradientBrush.Transform>
									<GradientStop Color="#FF323232" Offset="0"/>
									<GradientStop Color="#FF5D5D5D" Offset="1"/>
								</LinearGradientBrush>
							</Rectangle.Fill>
						</Rectangle>
						<ContentPresenter HorizontalAlignment="Center" x:Name="ContentPresenter" VerticalAlignment="Center" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/>
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsKeyboardFocused" Value="true"/>
						<Trigger Property="IsMouseOver" Value="true"/>
						<Trigger Property="IsPressed" Value="true"/>
						<Trigger Property="IsEnabled" Value="false">
							<Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
    
	<Style x:Key="ThumbStyle" d:IsControlPart="True" TargetType="{x:Type Thumb}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Thumb}">
					<Grid Margin="0,0,0,0" x:Name="Grid">
						<Rectangle HorizontalAlignment="Stretch" x:Name="Rectangle" VerticalAlignment="Stretch" Width="Auto" Height="Auto" RadiusX="2" RadiusY="2" Stroke="{x:Null}">
							<Rectangle.Fill>
								<LinearGradientBrush EndPoint="26.554,60.837" StartPoint="11.394,60.837" MappingMode="Absolute">
									<LinearGradientBrush.Transform>
										<MatrixTransform Matrix="1,0,0,-1,-10.333,70.167"/>
									</LinearGradientBrush.Transform>
									<GradientStop Color="#FF323232" Offset="0"/>
									<GradientStop Color="#FF5D5D5D" Offset="1"/>
								</LinearGradientBrush>
							</Rectangle.Fill>
						</Rectangle>
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsFocused" Value="True"/>
						<Trigger Property="IsMouseOver" Value="True"/>
						<Trigger Property="IsEnabled" Value="False"/>
						<Trigger Property="IsDragging" Value="True"/>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>
